﻿using System;

namespace MessagePack.Formatters
{
	// Token: 0x02000047 RID: 71
	public class NullableBooleanFormatter : IMessagePackFormatter<bool?>
	{
		// Token: 0x0600010B RID: 267 RVA: 0x0000496C File Offset: 0x00002D6C
		private NullableBooleanFormatter()
		{
		}

		// Token: 0x0600010C RID: 268 RVA: 0x00004974 File Offset: 0x00002D74
		public int Serialize(ref byte[] bytes, int offset, bool? value, IFormatterResolver formatterResolver)
		{
			if (value == null)
			{
				return MessagePackBinary.WriteNil(ref bytes, offset);
			}
			return MessagePackBinary.WriteBoolean(ref bytes, offset, value.Value);
		}

		// Token: 0x0600010D RID: 269 RVA: 0x0000499C File Offset: 0x00002D9C
		public bool? Deserialize(byte[] bytes, int offset, IFormatterResolver formatterResolver, out int readSize)
		{
			if (MessagePackBinary.IsNil(bytes, offset))
			{
				readSize = 1;
				return null;
			}
			return new bool?(MessagePackBinary.ReadBoolean(bytes, offset, out readSize));
		}

		// Token: 0x0400003B RID: 59
		public static readonly NullableBooleanFormatter Instance = new NullableBooleanFormatter();
	}
}
